﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;

namespace Aioms.Models
{
    ///<summary>
    /// 计划工单
    ///</summary>
    [SugarTable("tpworkorder")]
    public class TpWorkOrder
    {
        public TpWorkOrder()
        {
            this.Created = DateTime.Now;
            this.Updated = DateTime.Now;
        }
        /// <summary>
        /// 工单ID
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
        [JsonProperty("id")]
        public long Id { get; set; }

        /// <summary>
        /// 企业ID
        /// </summary>   
        [SugarColumn(ColumnName = "eid")]
        [JsonProperty("eid")]
        public long Eid { get; set; }

        /// <summary>
        /// 来源：报修、计划
        /// </summary>    
        [SugarColumn(ColumnName = "source")]
        [JsonProperty("source")]
        public string Source { get; set; }

        /// <summary>
        /// 引用来源ID
        /// </summary>   
        [SugarColumn(ColumnName = "refid")]
        [JsonProperty("refid")]
        public long RefId { get; set; }

        /// <summary>
        /// 工单单号
        /// </summary>    
        [SugarColumn(ColumnName = "number")]
        [JsonProperty("number")]
        public string Number { get; set; }

        /// <summary>
        /// 工单名称
        /// </summary>    
        [SugarColumn(ColumnName = "name")]
        [JsonProperty("name")]
        public string Name { get; set; }

        /// <summary>
        /// 工单类型
        /// </summary>    
        [SugarColumn(ColumnName = "type")]
        [JsonProperty("type")]
        public string Type { get; set; }

        /// <summary>
        /// 工单类型额外标识：日，月，周，年等
        /// </summary>    
        [SugarColumn(ColumnName = "extra")]
        [JsonProperty("extra")]
        public string Extra { get; set; }

        /// <summary>
        /// 维修开始时间
        /// </summary>           
        [SugarColumn(ColumnName = "begintime")]
        [JsonProperty("begintime")]
        public DateTime BeginTime { get; set; }

        /// <summary>
        /// 维修结束时间
        /// </summary>           
        [SugarColumn(ColumnName = "endtime")]
        [JsonProperty("endtime")]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 工时
        /// </summary>  
        [SugarColumn(ColumnName = "man_hour")]
        [JsonProperty("man_hour")]
        public int ManHour { get; set; }

        /// <summary>
        /// 实际维修开始时间
        /// </summary>           
        [SugarColumn(ColumnName = "sjbegintime")]
        [JsonProperty("sjbegintime")]
        public DateTime SjBeginTime { get; set; }

        /// <summary>
        /// 实际维修结束时间
        /// </summary>           
        [SugarColumn(ColumnName = "sjendtime")]
        [JsonProperty("sjendtime")]
        public DateTime SjEndTime { get; set; }

        /// <summary>
        /// 实际工时
        /// </summary>  
        [SugarColumn(ColumnName = "sjman_hour")]
        [JsonProperty("sjman_hour")]
        public decimal SjManHour { get; set; }

        /// <summary>
        /// 指派人ID，逗号分隔：1,2,3
        /// </summary>  
        [SugarColumn(ColumnName = "epids")]
        [JsonProperty("epids")]
        public string Epids { get; set; }

        /// <summary>
        /// 指派人姓名，逗号分隔：张三,李四,王五
        /// </summary>  
        [SugarColumn(IsIgnore = true)]
        [JsonProperty("eprealnames")]
        public string EpRealnames { get; set; } = "";

        /// <summary>
        /// 巡检路线下巡检点子数量/点检设备数量/保养设备数量
        /// </summary>  
        [SugarColumn(IsIgnore = true)]
        [JsonProperty("childrencount")]
        public int ChildrenCount { get; set; }

        /// <summary>
        /// 图片
        /// </summary>           
        [SugarColumn(ColumnName = "imageurl")]
        [JsonProperty("imageurl")]
        public string Imageurl { get; set; }

        /// <summary>
        /// 视频
        /// </summary>           
        [SugarColumn(ColumnName = "videourl")]
        [JsonProperty("videourl")]
        public string Videourl { get; set; }

        /// <summary>
        /// 语音
        /// </summary>           
        [SugarColumn(ColumnName = "voiceurl")]
        [JsonProperty("voiceurl")]
        public string Voiceurl { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>           
        [SugarColumn(ColumnName = "status")]
        [JsonProperty("status")]
        public string Status { get; set; }

        /// <summary>
        /// 实际维修人ID
        /// </summary>           
        [SugarColumn(ColumnName = "sjwxepid")]
        [JsonProperty("sjwxepid")]
        public long SjWxEpId { get; set; }

        /// <summary>
        /// 实际维修人姓名
        /// </summary>           
        [SugarColumn(ColumnName = "sjwxeprealname")]
        [JsonProperty("sjwxeprealname")]
        public string SjWxEpRealname { get; set; } = "";

        /// <summary>
        /// 进度
        /// </summary>           
        [SugarColumn(ColumnName = "progress", ColumnDataType = "text")]
        [JsonProperty("progress")]
        public string Progress { get; set; }

        /// <summary>
        /// 冗余巡检路线-巡检点-巡检项-巡检设备等信息
        /// </summary>           
        [SugarColumn(ColumnName = "taskinfo", ColumnDataType = "json", IsJson = true)]
        [JsonProperty("taskinfo")]
        public JObject TaskInfo { get; set; }

        /// <summary>
        /// 
        /// </summary>           
        [SugarColumn(ColumnName = "created")]
        [JsonProperty("created")]
        public DateTime Created { get; set; }

        /// <summary>
        /// 
        /// </summary>           
        [SugarColumn(ColumnName = "updated")]
        [JsonProperty("updated")]
        public DateTime Updated { get; set; }

        /// <summary>
        /// 
        /// </summary>           
        [SugarColumn(IsIgnore = true)]
        [JsonProperty("taskplan")]
        public TaskPlan TaskPlan { get; set; } = new();
    }
}
